package hms.RoomManagementModule;

import hms.rooms.RoomType;

import java.awt.BorderLayout;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.EmptyBorder;

public class EditRoomTypePanel extends JDialog {

	private final JPanel contentPanel = new JPanel();
	
	private RoomType roomType;

	protected JTextField txt_numBeds;
	protected JTextField txt_price;
	protected JTextField txt_bedSize;
	
	protected JLabel lblTypeLabel;
	
	private EditRoomTypePanel thisPanel;
	
	protected JButton btn_saveUpdatedType, btn_cancel, btn_remove;
	
	protected JCheckBox chk_refrigerator, chk_microwave, chk_couch, chk_pullOutCot, chk_desk,
		chk_ethernet, chk_hbo, chk_alarmClock, chk_balcony, chk_ceilingFan, chk_floorfan, chk_dvdRentals;
	
	protected JCheckBox chk_isSmokingAllowed;
	
	private ConfigureRoomsView view;
	
	/**
	 * Create the dialog.
	 */
	public EditRoomTypePanel(RoomType i_roomType, ConfigureRoomsView i_view) {
		
		thisPanel = this;
		
		roomType = i_roomType;
		view = i_view;
		setAlwaysOnTop(true);
		setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
		setResizable(false);
		setTitle("Edit Room Type");
		
		setBounds(100, 100, 581, 450);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		
		lblTypeLabel = new JLabel("Type Label: ");
		lblTypeLabel.setFont(new Font("Dialog", Font.PLAIN, 20));
		
		JLabel lblPrice = new JLabel("Price:");
		lblPrice.setFont(new Font("Dialog", Font.PLAIN, 20));
		
		JLabel lblBeds = new JLabel("Beds:");
		lblBeds.setFont(new Font("Dialog", Font.PLAIN, 20));
		
		JLabel lblBedSize = new JLabel("Bed Size:");
		lblBedSize.setFont(new Font("Dialog", Font.PLAIN, 20));
		
		chk_isSmokingAllowed = new JCheckBox("Is Smoking Allowed");
		chk_isSmokingAllowed.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		txt_numBeds = new JTextField();
		txt_numBeds.setFont(new Font("Roboto Cn", Font.PLAIN, 17));
		txt_numBeds.setColumns(10);
		
		txt_price = new JTextField();
		txt_price.setFont(new Font("Roboto Cn", Font.PLAIN, 17));
		txt_price.setColumns(10);
		
		txt_bedSize = new JTextField();
		txt_bedSize.setFont(new Font("Roboto Cn", Font.PLAIN, 17));
		txt_bedSize.setColumns(10);
		
		chk_refrigerator = new JCheckBox("Refrigerator");
		chk_refrigerator.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_microwave = new JCheckBox("Microwave");
		chk_microwave.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_couch = new JCheckBox("Couch");
		chk_couch.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_pullOutCot = new JCheckBox("Pull-out Cot");
		chk_pullOutCot.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_desk = new JCheckBox("Desk");
		chk_desk.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_ethernet = new JCheckBox("Ethernet");
		chk_ethernet.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_hbo = new JCheckBox("HBO");
		chk_hbo.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_alarmClock = new JCheckBox("Alarm Clock");
		chk_alarmClock.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_balcony = new JCheckBox("Balcony");
		chk_balcony.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_ceilingFan = new JCheckBox("Ceiling Fan");
		chk_ceilingFan.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		
		chk_floorfan = new JCheckBox("Floor Fan");
		chk_floorfan.setFont(new Font("Roboto Cn", Font.PLAIN, 20));

		chk_dvdRentals = new JCheckBox("DVD Rentals");
		chk_dvdRentals.setFont(new Font("Roboto Cn", Font.PLAIN, 20));
		GroupLayout gl_contentPanel = new GroupLayout(contentPanel);
		gl_contentPanel.setHorizontalGroup(
			gl_contentPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPanel.createSequentialGroup()
							.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
								.addComponent(lblBedSize)
								.addComponent(lblBeds, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
								.addComponent(lblPrice))
							.addGap(30)
							.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
								.addComponent(txt_bedSize, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE)
								.addComponent(txt_numBeds, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
								.addComponent(txt_price, GroupLayout.PREFERRED_SIZE, 136, GroupLayout.PREFERRED_SIZE)))
						.addComponent(chk_refrigerator, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_microwave, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_couch, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_pullOutCot, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_desk, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_hbo, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblTypeLabel, GroupLayout.PREFERRED_SIZE, 321, GroupLayout.PREFERRED_SIZE))
					.addGap(18)
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
						.addComponent(chk_dvdRentals, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_floorfan, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_ceilingFan, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_balcony, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_alarmClock, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_ethernet, GroupLayout.PREFERRED_SIZE, 145, GroupLayout.PREFERRED_SIZE)
						.addComponent(chk_isSmokingAllowed))
					.addGap(33))
		);
		gl_contentPanel.setVerticalGroup(
			gl_contentPanel.createParallelGroup(Alignment.LEADING)
				.addGroup(gl_contentPanel.createSequentialGroup()
					.addContainerGap()
					.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
						.addGroup(gl_contentPanel.createSequentialGroup()
							.addComponent(chk_isSmokingAllowed)
							.addGap(67)
							.addComponent(chk_ethernet, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_alarmClock, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_balcony, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_ceilingFan, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_floorfan, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_dvdRentals, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addContainerGap())
						.addGroup(gl_contentPanel.createSequentialGroup()
							.addComponent(lblTypeLabel)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
								.addGroup(gl_contentPanel.createSequentialGroup()
									.addComponent(lblPrice, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(lblBeds, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE))
								.addGroup(gl_contentPanel.createSequentialGroup()
									.addComponent(txt_price, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
									.addPreferredGap(ComponentPlacement.RELATED)
									.addComponent(txt_numBeds, 0, 0, Short.MAX_VALUE)))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
								.addComponent(lblBedSize, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
								.addComponent(txt_bedSize, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE))
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_refrigerator, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_microwave, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_couch, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_pullOutCot, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_desk, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addPreferredGap(ComponentPlacement.RELATED)
							.addComponent(chk_hbo, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
							.addContainerGap(28, Short.MAX_VALUE))))
		);
		contentPanel.setLayout(gl_contentPanel);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				btn_saveUpdatedType = new JButton("Save");
				btn_saveUpdatedType.setActionCommand("btn_saveUpdatedType");
				btn_saveUpdatedType.addActionListener(view);
				buttonPane.add(btn_saveUpdatedType);
				getRootPane().setDefaultButton(btn_saveUpdatedType);
			}
			{
				btn_cancel = new JButton("Cancel");
				btn_cancel.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						thisPanel.dispose();
					}
				});
				
				btn_remove = new JButton("Remove Type");
				btn_remove.setActionCommand("btn_remove");
				btn_remove.addActionListener(view);
				buttonPane.add(btn_remove);
				buttonPane.add(btn_cancel);
			}
		}
	}
}
